package quickstats;

import static org.junit.Assert.*;

/**
 * Test cases for the BivariateCalculator class
 */

import java.text.DecimalFormat;
import java.util.Arrays;

import org.junit.Test;

public class BivariateCalculatorTest extends BivariateCalculator {

	/*
	 * 5 test cases to test sum computation
	 */
	@Test
	public void testComputeSum() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10};
		double[] sample3 = {-1, -2, -3, -4, -5, 0, 10, 10, 10, 10};
		double[] sample4 = {1000000000, 1000000000, 0};
		double[] sample5 = {-1000000000, -1000000000};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {55, -55, 25, 2000000000, -2000000000};
		
		for (int i = 0, j = 1; i < samples.length; i++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeSum();
			if (answers[i] != super.sampleOne_sum) fail("computeSum sampleOne_sum sample " + j + " has failed the test");
			if (answers[i] != super.sampleTwo_sum) fail("computeSum sampleTwo_sum sample " + j + " has failed the test");
		}
	}
	
	/*
	 * 5 test cases to test mean computation
	 */
	@Test
	public void testComputeMean() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10};
		double[] sample3 = {-1, -2, -3, -4, -5, 0, 10, 10, 10, 10};
		double[] sample4 = {1000000000, 1000000000, 0};
		double[] sample5 = {-1000000000, -1000000000};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {5.5, -5.5, 2.5, 666666666.66666666666666666666667, -1000000000};
		
		for (int i = 0, j = 1; i < samples.length; i++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMean();
			if (answers[i] != super.sampleOne_mean) fail("computeMean sampleOne_mean sample " + j + " has failed the test");
			if (answers[i] != super.sampleTwo_mean) fail("computeMean sampleTwo_mean sample " + j + " has failed the test");
		}
	}
	
	/*
	 * 5 test cases to test median computation
	 */
	@Test
	public void testComputeMedian() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -7, -8, -9, -10};
		double[] sample3 = {-1, -2, -3, -4, -5, 0, 10, 10, 10, 10};
		double[] sample4 = {1000000000, 1000000000, 0};
		double[] sample5 = {0};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {5.5, -5.5, -0.5, 1000000000, 0};
		
		for (int i = 0, j = 1; i < samples.length; i++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMedian();
			if (answers[i] != super.sampleOne_median) fail("computeMedian sampleOne_median sample " + j + " has failed the test");
			if (answers[i] != super.sampleTwo_median) fail("computeMedian sampleTwo_median sample " + j + " has failed the test");

		}
	}
	
	/*
	 * 5 test cases for computing mode
	 */
	@Test
	public void testComputeMode() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-1, -3, -3, -1, -1, 0, 10, 10, 10, 10};
		double[] sample4 = {1000000000, 1000000000, 0, -100, 0};
		double[] sample5 = {-1, 2, -3, -1, 2, -3};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		String[] answers = {"[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0]", "[-3.0]", "[10.0]", "[0.0, 1.0E9]", "[-3.0, -1.0, 2.0]"};
		
		for (int i = 0, j = 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMode();
			if (!answers[i].trim().equals(super.sampleOne_mode.trim())) fail("computeMode sampleOne_mode sample " + j + " has failed the test");
			if (!answers[i].trim().equals(super.sampleOne_mode.trim())) fail("computeMode sampleOne_mode sample " + j + " has failed the test");
			//assertEquals(answers[i], super.mode);
		}
	}
	
	/*
	 * 5 tests cases to find the maximum value
	 */
	@Test
	public void testComputeMax() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-1000};
		double[] sample4 = {1000000000, 1000000000, 0, -1000000000, 999999999};
		double[] sample5 = {0, 0, 0, 0, 0, 0};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {10, -1, -1000, 1000000000, 0};
		
		for (int i = 0, j = 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMax();
			if (answers[i] != (super.sampleOne_max)) fail("computeMax sampleOne_max sample " + j + " has failed the test");
			if (answers[i] != (super.sampleTwo_max)) fail("computeMax sampleTwo_max sample " + j + " has failed the test");
		}
	}
	
	/*
	 * 5 tests cases to compute minimum value
	 */
	@Test
	public void testComputeMin() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-1000};
		double[] sample4 = {1000000000, 1000000000, 0, -1000000000, 999999999};
		double[] sample5 = {0, 0, 0, 0, 0, 0};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {1, -10, -1000, -1000000000, 0};
		
		for (int i = 0, j = 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMin();
			if (answers[i] != (super.sampleOne_min)) fail("computeMin sampleOne_min sample " + j + " has failed the test");
			if (answers[i] != (super.sampleTwo_min)) fail("computeMin sampleTwo_min sample " + j + " has failed the test");

		}
	}
	
	/*
	 * 5 test cases to compute range
	 */
	@Test
	public void testComputeRange() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-1000};
		double[] sample4 = {1000000000, 1000000000, 0, -1000000000, 999999999};
		double[] sample5 = {0, 0, 0, 0, 0, 0};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {9, 9, 0, 2000000000, 0};
		
		for (int i = 0, j = 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMin();
			computeMax();
			computeRange();
			if (answers[i] != (super.sampleOne_range)) fail("computeRange sampleOne_range sample " + j + " has failed the test");
			if (answers[i] != (super.sampleTwo_range)) fail("computeRange sampleTwo_range sample " + j + " has failed the test");
		}
	}
	
	/*
	 * 5 test cases for geometric mean 
	 * only numbers greater than greater than zero will work
	 * geometric mean does not calculate data with zeros or less
	 */
	@Test
	public void testComputeGeometricMean() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {1000, 1, 2, 3, 4, 5, 6, 3, 8, 9, 10};
		double[] sample3 = {1000};
		double[] sample4 = {1, 1, 1, 1, 1};
		double[] sample5 = {243, 456, 4386, 46589, 398475, 946};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {4.52873, 6.848838598, 1000, 1, 4520.667423};
		
		for (int i = 0, j = 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeGeometricMean();
			if (roundDouble(answers[i]) != roundDouble(super.sampleOne_geometricmean)) fail("computeGeometricMean sampleOne_geometricmean sample " + j + " has failed the test");
			if (roundDouble(answers[i]) != roundDouble(super.sampleTwo_geometricmean)) fail("computeGeometricMean sampleTwo_geometricmean sample " + j + " has failed the test");

		}
	}
	
	/*
	 * 5 test cases for skewness
	 */
	@Test
	public void testComputeSkewness() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-4, -3, -2, -1, 0, 1, 2, 3, 4, 5};
		double[] sample4 = {1, 1, 1, 1, 2};
		double[] sample5 = {1, 0, 0, 0, 0, 0};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {0, -0.400368792, 0, 2.236067977, 2.449489743};
		
		for (int i = 2, j = i + 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMean();
			computeSkewness();
			if (roundDoubleWhole(answers[i]) != roundDoubleWhole(super.sampleOne_skewness)) fail("computeSkewness sampleOne_skewness sample " + j + " has failed the test");
			if (roundDoubleWhole(answers[i]) != roundDoubleWhole(super.sampleTwo_skewness)) fail("computeSkewness sampleTwo_skewness sample " + j + " has failed the test");
		}
	}
	
	/*
	 * 5 test cases for computing kurtosis
	 */
	@Test
	public void testComputeKurtosis() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-4, -3, -2, -1, 0, 1, 2, 3, 4, 5};
		double[] sample4 = {1, 1, 1, 1, 2};
		double[] sample5 = {1, 0, 0, 0, 0, 0};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {1.77575757576, 1.79591454507, 1.77575757576, 3.25, 4.2};
		
		for (int i = 0, j = 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMean();
			computeKurtosis();
			if (roundDouble(answers[i]) != roundDouble(super.sampleOne_kurtosis)) fail("computeKurtosis sampleOne_kurtosis sample " + j + " has failed the test");
			if (roundDouble(answers[i]) != roundDouble(super.sampleTwo_kurtosis)) fail("computeKurtosis sampleTwo_kurtosis sample " + j + " has failed the test");
		}
	}
	
	/*
	 * 5 test cases for computing excess kurtosis
	 */
	@Test
	public void testComputeExcessKurtosis() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-4, -3, -2, -1, 0, 1, 2, 3, 4, 5};
		double[] sample4 = {1, 1, 1, 1, 2};
		double[] sample5 = {1, 0, 0, 0, 0, 0};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {-1.242424244, -1.20408545493, -1.22424242424, 0.25, 1.2};
		
		for (int i = 0, j = 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMean();
			computeKurtosis();
			computeExcessKurtosis();
			if (roundDoubleTenth(answers[i]) != roundDoubleTenth(super.sampleOne_excesskurtosis)) fail("computeExcessKurtosis sampleOne_excesskurtosis sample " + j + " has failed the test");
			if (roundDoubleTenth(answers[i]) != roundDoubleTenth(super.sampleTwo_excesskurtosis)) fail("computeExcessKurtosis sampleTwo_excesskurtosis sample " + j + " has failed the test");
		}
	}
	
	/*
	 * 5 test cases to compute variance
	 */
	@Test
	public void testComputeVariance() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-4, -3, -2, -1, 0, 1, 2, 3, 4, 5};
		double[] sample4 = {1, 1, 1, 1, 1};
		double[] sample5 = {1, 0, 0, 0, 0, 0};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {8.25, 8.49, 8.25, 0, 0.138889};
		
		for (int i = 0, j = 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMean();
			computeVariance();
			if (roundDouble(answers[i]) != roundDouble(super.sampleOne_variance)) fail("computeVariance sampleOne_variance sample " + j + " has failed the test");
			if (roundDouble(answers[i]) != roundDouble(super.sampleTwo_variance)) fail("computeVariance sampleTwo_variance sample " + j + " has failed the test");
		}
	}
	
	/*
	 * 5 tests for standard deviation
	 */
	@Test
	public void testComputeStddev() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-4, -3, -2, -1, 0, 1, 2, 3, 4, 5};
		double[] sample4 = {1, 1, 1, 1, 1};
		double[] sample5 = {1, 0, 0, 0, 0, 0};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		double[] answers = {3.02765, 3.07137, 3.02765, 0, 0.40825};
		
		for (int i = 0, j = 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMean();
			computeStddev();
			if (roundDouble(answers[i]) != roundDouble(super.sampleOne_stddev)) fail("computeStddev sampleOne_stddev sample " + j + " has failed the test");
			if (roundDouble(answers[i]) != roundDouble(super.sampleTwo_stddev)) fail("computeStddev sampleTwo_stddev sample " + j + " has failed the test");
		}
	}
	
	/*
	 * 5 test cases to compute first, second, third and fourth quartiles
	 */
	@Test
	public void testComputeQuartiles() {
		double[] sample1 = {6, 7, 15, 36, 39, 40, 41, 42, 43, 47, 49};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-4, -3, -2, -1, 0, 1, 2, 3, 4, 5};
		double[] sample4 = {1, 1, 1, 1, 1};
		double[] sample5 = {1, 0, 0, 0, 0, 0};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		
		double[] answers1 = {15, -8, -2, 1, 0};
		double[] answers2 = {40, -4, 1, 1, 0};
		double[] answers3 = {43, -3, 3, 1, 0};
		double[] answers4 = {49, -1, 5, 1, 1};
		
		for (int i = 0, j = 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeQuartiles();
			if (roundDoubleWhole(answers1[i]) != roundDoubleWhole(super.sampleOne_firstquartile)) fail("computeQuartiles sampleOne_firstquartile sample " + j + " has failed the test");
			if (roundDoubleWhole(answers2[i]) != roundDoubleWhole(super.sampleOne_secondquartile)) fail("computeQuartiles sampleOne_ secondquartile sample " + j + " has failed the test");
			if (roundDoubleWhole(answers3[i]) != roundDoubleWhole(super.sampleOne_thirdquartile)) fail("computeQuartiles sampleOne_thirdquartile sample " + j + " has failed the test");
			if (roundDoubleWhole(answers4[i]) != roundDoubleWhole(super.sampleOne_fourthquartile)) fail("computeQuartiles sampleOne_fourthquartile sample " + j + " has failed the test");
			if (roundDoubleWhole(answers1[i]) != roundDoubleWhole(super.sampleTwo_firstquartile)) fail("computeQuartiles sampleTwo_firstquartile sample " + j + " has failed the test");
			if (roundDoubleWhole(answers2[i]) != roundDoubleWhole(super.sampleTwo_secondquartile)) fail("computeQuartiles sampleTwo_ secondquartile sample " + j + " has failed the test");
			if (roundDoubleWhole(answers3[i]) != roundDoubleWhole(super.sampleTwo_thirdquartile)) fail("computeQuartiles sampleTwo_thirdquartile sample " + j + " has failed the test");
			if (roundDoubleWhole(answers4[i]) != roundDoubleWhole(super.sampleTwo_fourthquartile)) fail("computeQuartiles sampleTwo_fourthquartile sample " + j + " has failed the test");
		}
	}
	
	/*
	 * 5 tests to compute first, second, third and fourth interquartile ranges
	 */
	@Test
	public void testComputeInterquartilerange() {
		double[] sample1 = {6, 7, 15, 36, 39, 40, 41, 42, 43, 47, 49};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-4, -3, -2, -1, 0, 1, 2, 3, 4, 5};
		double[] sample4 = {1, 1, 1, 1, 1};
		double[] sample5 = {1, 0, 0, 0, 0, 0};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		
		double[] answers1 = {9, 2, 2, 0, 0};
		double[] answers2 = {25, 4, 3, 0, 0};
		double[] answers3 = {3, 1, 2, 0, 0};
		double[] answers4 = {6, 2, 2, 0, 1};
		
		for (int i = 0, j = i + 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeMin();
			computeQuartiles();
			computeInterquartilerange();
			if (roundDoubleWhole(answers1[i]) != roundDoubleWhole(super.sampleOne_firstinterquartilerange)) fail("computeInterauartilerange sampleOne_firstinterquartilerange sample " + j + " has failed the test");
			if (roundDoubleWhole(answers2[i]) != roundDoubleWhole(super.sampleOne_secondinterquartilerange)) fail("computeinterquartilerange sampleOne_secondinterquartilerange sample " + j + " has failed the test");
			if (roundDoubleWhole(answers3[i]) != roundDoubleWhole(super.sampleOne_thirdinterquartilerange)) fail("computeinterquartilerange sampleOne_thirdinterquartilerange sample " + j + " has failed the test");
			if (roundDoubleWhole(answers4[i]) != roundDoubleWhole(super.sampleOne_fourthinterquartilerange)) fail("computeinterquartilerange sampleOne_fourthinterquartilerange sample " + j + " has failed the test");
			if (roundDoubleWhole(answers1[i]) != roundDoubleWhole(super.sampleTwo_firstinterquartilerange)) fail("computeInterauartilerange sampleTwo_firstinterquartilerange sample " + j + " has failed the test");
			if (roundDoubleWhole(answers2[i]) != roundDoubleWhole(super.sampleTwo_secondinterquartilerange)) fail("computeinterquartilerange sampleTwo_secondinterquartilerange sample " + j + " has failed the test");
			if (roundDoubleWhole(answers3[i]) != roundDoubleWhole(super.sampleTwo_thirdinterquartilerange)) fail("computeinterquartilerange sampleTwo_thirdinterquartilerange sample " + j + " has failed the test");
			if (roundDoubleWhole(answers4[i]) != roundDoubleWhole(super.sampleTwo_fourthinterquartilerange)) fail("computeinterquartilerange sampleTwo_fourthinterquartilerange sample " + j + " has failed the test");
		}
	}
	
	/*
	 * 5 test cases to test frequency distributions
	 */
	@Test
	public void testComputeFrequencydist() {
		double[] sample1 = {1, 2, 3, 4, 5};
		double[] sample2 = {-1, -2, -3, -4, -5, -1, -2, -3, -4, -5};
		double[] sample3 = {-4, -3, -2, -1, 0, -1, -1, -1, -1};
		double[] sample4 = {1, 1, 1, 1, 1};
		double[] sample5 = {1, 0, 0, 0, -1};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5};
		
		int[] answers1 = {1, 1, 1, 1, 1};
		int[] answers2 = {2, 2, 2, 2, 2};
		int[] answers3 = {1, 1, 1, 5, 1};
		int[] answers4 = {5};
		int[] answers5 = {1, 3, 1};
		Object[] answerSets = {answers1, answers2, answers3, answers4, answers5};
		
		for (int i = 0, j = i + 1; i < samples.length; i++, j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i];
			computeFrequencydist();
			if (super.freqCount2.length != ((int[]) answerSets[i]).length) fail("computeFrequencydist sampleOne_frequencydist sample " + j + " has failed the test");;
			if (super.freqCount4.length != ((int[]) answerSets[i]).length) fail("computeFrequencydist sampleTwo_frequencydisk sample " + j + " has failed the test");;
			if (!Arrays.equals(super.freqCount2, (int[]) answerSets[i])) fail("computeFrequencydist sampleOne_frequencydist sample " + j + " has failed the test");
			if (!Arrays.equals(super.freqCount4, (int[]) answerSets[i])) fail("computeFrequencydist sampleTwo_frequencydist sample " + j + " has failed the test");

		}
	}
	
	/*
	 * 5 test cases with 10 arrays
	 * 2 arrays per test
	 * Does not test inputs that output NaN
	 * Uses WolframAlpha to calculate non-rounded coefficient
	 */
	@Test
	public void testComputePearsonCorrelation() {
		double[] sample1 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample2 = {-1, -2, -3, -4, -5, -6, -3, -8, -9, -10};
		double[] sample3 = {-4, -3, -2, -1, 0, 1, 2, 3, 4, 5};
		double[] sample4 = {-40, -30, -20, -20, 0, 10, 20, 30, 40, 50};
		double[] sample5 = {1, 2, 1, 2, 1, 2, 1, 2, -1, -2};
		double[] sample6 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
		double[] sample7 = {-1000, 0 , 1000};
		double[] sample8 = {1, 2, -3};
		double[] sample9 = {-100, -100, 0, -100, -100};
		double[] sample10 = {100, 100, 0, 100, 100};
		Object[] samples = {sample1, sample2, sample3, sample4, sample5, sample6, sample7, sample8, sample9, sample10};
		double[] answers = {-0.914072, 0.994937, -0.60258, -0.755929, -1};
		
		for (int i = 0, j = 1; i < samples.length; j++) {
			super.sampleOne = (double[]) samples[i];
			super.sampleTwo = (double[]) samples[i + 1];
			computePearsonCorrelation();
			if (roundDouble(answers[i/2]) != roundDouble(super.pearsoncorrelation)) fail("computePearsonCorrelation sample " + j + " has failed the test");
			i += 2;
		}
	}
	
	/*
	 * Rounds numbers to account for very large decimal places
	 */
	public double roundDouble(double d) {
		DecimalFormat twoDForm = new DecimalFormat("#.###");
		return Double.valueOf(twoDForm.format(d));
	}
	
	/*
	 * Rounds numbers to first decimal place for excess kurtosis
	 */
	public double roundDoubleWhole(double d) {
		DecimalFormat twoDForm = new DecimalFormat("#");
		return Double.valueOf(twoDForm.format(d));
	}
	
	/*
	 * Rounds numbers to first decimal place for excess kurtosis
	 */
	public double roundDoubleTenth(double d) {
		DecimalFormat twoDForm = new DecimalFormat("#.#");
		return Double.valueOf(twoDForm.format(d));
	}
}
